package thread.wang_bao_ling.c22.executors.wheel;

import java.util.concurrent.TimeUnit;

/**
 * @Auther: luobiao
 * @Date: 2021/3/20 10:18
 * @Description:
 */
public class Test {
    public static void main(String[] args){
        MyHashedWheelTimer timeWheel = new MyHashedWheelTimer(TimeUnit.SECONDS,1,8);
        long now = System.currentTimeMillis();
        System.out.println("当前系统时间=" + System.currentTimeMillis());

        timeWheel.add(() -> {
            System.out.println("task1 run...，延时执行毫秒数 =" + (System.currentTimeMillis() - now));
        }, System.currentTimeMillis() + 1000 * 3, TimeUnit.MILLISECONDS);

        timeWheel.add(() -> {
            System.out.println("task2 run...，延时执行毫秒数=" +(System.currentTimeMillis() - now));
        }, System.currentTimeMillis() + 1000 * 10, TimeUnit.MILLISECONDS);

        timeWheel.add(() -> {
            System.out.println("task3 run...，延时执行毫秒数=" + (System.currentTimeMillis() - now));
        }, System.currentTimeMillis() + 1000 * 20, TimeUnit.MILLISECONDS);
    }
}
